package lexical;

import java.lang.reflect.Field;

public class RegexDemo {


    public static String LineTerminator = "\\r|\\n|\\r\\n";

    // 自定义标识符
    public static String id_pattern = "[a-zA-Z_][0-9a-zA-Z_]*";

    // 字符串
    public static String str_pattern = "('(?:(?!').)*')|(\"(?:(?!\").)*\")";


    // 注释

    public static String End_Line_Comment = "#[ |\\S|\\s]*[" + LineTerminator + "]?";

    public static String Traditional_Comment = "'''(?:(?!''').|[\\n\\r])*'''";

    public static String Documentation_Comment = "\"\"\"(?:(?!\"\"\").|[\\n\\r])*\"\"\"";

    //    public static String comment_pattern = String.format("(%s)|(%s)|(%s)",End_Line_Comment ,Traditional_Comment , Documentation_Comment);
    public static String Comment = String.format("(%s)|(%s)|(%s)", "End_Line_Comment", "Traditional_Comment", "Documentation_Comment");

    public static String FloatNumber = "^(-?([1-9]|0)[0-9]*)((\\.[0-9]+)|(e-?[0-9]+))+$";

    public static String ComplexNumber = String.format("%s(+|-)%s(j|J)", FloatNumber, FloatNumber);

    public static void main(String[] args) throws IllegalAccessException {
        RegexDemo demo = new RegexDemo();
        Field[] fields = RegexDemo.class.getFields();
        for (Field f : fields) {
            String name = f.getName();
            String val = (String) f.get(demo);
            String s = String.format("%s\t=\t%s", name, val);
            System.out.println(s);
        }

    }


}
